<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var arr = ['张飞0', '关羽1', '刘备2', '猴子3', '黑鸟4', '剑圣5'];
        Array.prototype.splice2 = function (num1, num2) {
            var num3 = [];
            for (var i = 0; i < arr.length; i++) {
                if (i >= num1 && i < num1 + num2) {
                    num3.push(arr[i]);
                }
            } // num3 是筛选出来的 
            var arr1 = [];
            for (var i = 0; i < arr.length; i++) {
                if (num3.indexOf(arr[i]) == -1) {
                    arr1.push(arr[i]);
                }
            }
            arr = arr1;
            if (arguments != null) { // 替换
                var arr2 = [];
                for (var i = 0; i < arr.length; i++) {
                    if (i < num1) {
                        arr2.push(arr[i]);
                    }
                }
                for (var i = 2; i < arguments.length; i++) {
                    arr2.push(arguments[i]);
                }
                for (var i = 0; i < arr.length; i++) {

                    if (i >= num1) {
                        arr2[arr2.length] = arr[i];
                    }
                }
                arr = arr2;
            }
        }
        arr.splice2(1, 2, 'a', 'a');
        console.log(arr);
    </script>
</body>

</html>